package com.sskj.login;

import org.springframework.web.bind.annotation.*;

/**
 * @Author: Like
 * @Date: 2023/11/21 14:37
 * @Description:
 */
@RestController
@RequestMapping("/login")
public class LoginController {
    /**
     * TODO：获得验证码示例
     * @param key
     * @return
     */
    @PostMapping("/sendCode")
    public String sendCode(@RequestParam String key){
        String code = VerificationCodeGenerator.generateCode(key);
        return code;
    }

    /**
     * TODO：验证实例
     *
     * @param key
     * @param code
     * @return
     */
    @GetMapping("/check")
    public String login1(@RequestParam String key,@RequestParam String code){
        boolean verified = VerificationCodeGenerator.verifyCode(key, code);
        return verified ? "验证码正确" : "验证码错误";
    }
}